#include "Tile.h"

// default constructor
Tile::Tile() {}

// default destructor make sure release is called
Tile::~Tile() { release(); }

// safetly release all data
void Tile::release()
{
	m_tex.release();
}

// setup tile of given type
void Tile::initialize(V2DF pos, int tileType)
{
	// load texture
	m_tex.initialize(L"images/tileset.png",2,1,2,32,32,true);
	// setup bounds
	m_bounds.top = m_tex.SpriteHeight()/-2.0f;
	m_bounds.bottom = m_tex.SpriteHeight()/2.0f;
	m_bounds.left = m_tex.SpriteWidth()/-2.0f;
	m_bounds.right = m_tex.SpriteWidth()/2.0f;
	// set tileType
	m_tileType = tileType;
	m_tex.setCurrentSprite(m_tileType);
	// set position
	m_position = pos;
}

void Tile::render()
{
	m_tex.draw(m_position,0.0f,1.0f);
}

void Tile::update(float dT) {}

// returns collision boundry relative to position
FRect Tile::getBounds()
{
	FRect temp = m_bounds;
	temp.right += m_position.x;
	temp.left += m_position.x;
	temp.top += m_position.y;
	temp.bottom += m_position.y;
	return temp;
}